#define _CRT_SECURE_NO_WARNINGS

class Solution {
public:
    int longestOnes(vector<int>& nums, int k) {
        int left = 0, right = 0;
        int n = nums.size();
        int len = 0;
        int num = 0;
        while (right < n)
        {
            if (nums[right] == 0)
            {
                num++;
            }

            while (num > k)
            {
                if (nums[left] == 0)
                {
                    num--;
                }
                left++;
            }

            len = max(len, right - left + 1);
            right++;
        }

        return len;
    }
};

int main()
{
    return 0;
}